package com.dhecp.project.system.controller;

import com.dhecp.common.core.controller.BaseController;
import com.dhecp.common.core.page.TableDataInfo;
import com.dhecp.core.constant.ModuleTable;
import com.dhecp.project.system.domain.SysOrganizationInfo;
import com.dhecp.project.system.service.SysOrganizationInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @program: kjecp
 * @description: 组织机构信息
 * @author: hlf
 * @create: 2023-06-01 09:01
 */
@Controller
@RequestMapping("/system/organization")
public class SysOrganizationController extends BaseController {
    private String prefix = "system/organization";
    private String moduleTable = ModuleTable.ORGANIZATION_INFO;


    @Autowired
    private SysOrganizationInfoService organizationInfoService;

    /**
     * 查询调入组织机构对象
     * @param params
     * @return TableDataInfo
     * @author DH-Xxj
     */
    @RequestMapping("/orgObject")
    @ResponseBody
    public TableDataInfo organizationInfoObject(@RequestParam Map<String, Object> params){
        if (params.get("moduleTable") == null || params.get("moduleTable") == ""){
            params.put("moduleTable", moduleTable);
        }
        List<SysOrganizationInfo> list = new ArrayList<SysOrganizationInfo>();
        try {
            list = organizationInfoService.queryOrganizationInfoObject(params);
        } catch (Exception e) {
            e.printStackTrace();
            return getDataTable(this.getExceptionMessage(e).toString());
        }
        return getDataTable(list);
    }

    /**
     * 查询调入组织机构对象
     * @param params
     * @return TableDataInfo
     * @author DH-Xxj
     */
    @RequestMapping("/orgObjectByIdOrName")
    @ResponseBody
    public TableDataInfo orgObjectByIdOrNameInfoObject(@RequestParam Map<String, Object> params){
        if (params.get("moduleTable") == null || params.get("moduleTable") == ""){
            params.put("moduleTable", moduleTable);
        }
        List<SysOrganizationInfo> list = new ArrayList<SysOrganizationInfo>();
        try {
            list = organizationInfoService.queryOrganizationInfoObjectByIdOrName(params);
        } catch (Exception e) {
            e.printStackTrace();
            return getDataTable(this.getExceptionMessage(e).toString());
        }
        return getDataTable(list);
    }

}